var RpcClient = require('./frame/RpcClient.js');
var service = require('./servers/ServerTime.js')

var cli = new RpcClient(service);

setTimeout(function() {
	cli.getCurrTime("hello", "world", function(hour, min, sec) {
		console.log('rpc result:', hour, min, sec);
	});

	cli.add("hello", " world", function(res) {
		console.log('rpc result:', res);
	});

	// test send 1000 req

	// return;
	var count = 1000;  
	// about 22,000ms @ vmware ubuntu
	// about 10,000ms @ server 2 (windows+ubuntu)
	var received = 0;
	var start = new Date().getTime();
	for (var i = 0; i < count; i++) {
		cli.echo("hello", function(res) {
			// console.log('rpc result:', res);
			received++;
			if (received === count) {
				var dt = new Date().getTime() - start;
				console.log('%d rpc cost time =%s ms', count, dt);
			}
		});
	}
}, 1000);